import Message from "./message";

let messageInstance;

function getMessageInstance() {
  messageInstance = messageInstance || Message.instance();
  return messageInstance;
}

function message(opt) {
  let duration, content;
  if (typeof opt === "string") {
    duration = 1500;
    content = opt || "";
  } else {
    duration = opt.duration || 1500;
    content = opt.content || "";
  }
  let instance = getMessageInstance();
  instance.add({
    duration,
    content,
  });
}

export default {
  info(options) {
    return message(options);
  },
};
